package com.hava.contentsale.utils.character;

import org.apache.commons.lang.CharSet;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;


/**
 * Created by zhanpeng on 17/11/2016.
 * TODO:read the config encoding and set for the getBytes
 */

@Component("global")
public class Encoding {

    @Value("${character.encoding}")
    String Value;

    public byte [] getBytes(String str)
    {
        try {
            return str.getBytes(this.Value);
        } catch (UnsupportedEncodingException e) {
            System.out.println("Class Encoding Method getBytes [Exception]:" + e.toString());
            return str.getBytes();
        }
    }
}
